/*代理端——点数配置*/
import request from '@/utils/request';
import { object2Url } from '@/utils/trans';

// 获取所有商户
export async function getMerchant(data) {
  const res = await request.post(
    '/business/MerchantManagement/listMerchant',
    data
  );
  if (res.data.code === 2000) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

// 新增点数配置
export async function pointAdd(data) {
  const res = await request.post('/business/pointAllocation/add', data);
  if (res.data.code === 2000) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

// 查询点数配置
export async function pageList(data) {
  const res = await request.post('/business/pointAllocation/pageList', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

// 代理基础设置——上传图片
export async function saveImg(data) {
  const res = await request.post('/business/systemConfiguration/saveImg', data);
  if (res.data.code === 2000) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

// 代理基础设置——删除接口
export async function delFile(data) {
  const res = await request.post(
    '/business/systemConfiguration/deleteImg',
    data
  );
  if (res.data.code === 2000) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

// 代理基础设置——查询接口
export async function query(data) {
  const res = await request.post(
    '/business/systemConfiguration/configurationQuery',
    data
  );
  if (res.data.code === 2000) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

// 商家端查询代理基础设置——查询接口
export async function getMerchantQuery(data) {
  const res = await request.post(
    '/business/systemConfiguration/getMerchantSystemConfig',
    data
  );
  if (res.data.code === 2000) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

// 登录查询配置
export async function getAddressConfiguration(data) {
  const res = await request.post(
    '/business/oemAgent/getAddressConfiguration',
    data
  );
  if (res.data.code === 2000) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

// 代理基础设置——查询接口
export async function fileListApi(data) {
  const res = await request.post('/business/systemConfiguration/pageImg', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

// 代理基础设置——保存提交
export async function save(data) {
  const res = await request.post(
    '/business/systemConfiguration/configurationAdd',
    data
  );
  if (res.data.code === 2000) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

// 保存神龙IP配置
export async function savePackageId(data) {
  const res = await request.post(
    '/business/systemConfiguration/savePackageId',
    data
  );
  if (res.data.code === 2000) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

// 查询神龙IP配置
export async function qureyPackageId(data) {
  const res = await request.post(
    '/business/systemConfiguration/pagePackageId',
    data
  );
  if (res.data.code === 2000) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

// 保存阿里云配置
export async function saveOss(data) {
  const res = await request.post('/business/aliyunoss/save', data);
  if (res.data.code === 2000) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

// 查询阿里云配置
export async function queryOss(data) {
  const res = await request.post('/business/aliyunoss/selectOemId', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

// 抖支付配置 oem支付配置新增接口
export async function dsfoempayconfigAdd(data) {
  const res = await request.post('/business/dsfoempayconfig/add', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}
//oem支付配置修改接口
export async function dsfoempayconfigUpdate(data) {
  const res = await request.post('/business/dsfoempayconfig/update', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}
// oem支付配置查询接口
export async function dsfoempayconfigGet(data) {
  const res = await request.post(
    '/business/dsfoempayconfig/getOemPayConfigInfo',
    data
  );
  if (res.data.code === 2000) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}
